/**************************************************************************
 * @name: None
 * @brief: None
 * @Date: 2025/02/10
 * @author: boluzs@163.com
 * @note: None
 * @version: 1.0.0
 * @Copyright (c) 2025 by boluzs@163.com, All Rights Reserved.
 **************************************************************************/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
int main()
{
    int cnt = 0; // 作为计数器

    int pipefd[2] = {0};
    pipe2(pipefd, O_NONBLOCK); // 以非阻塞方式创建

    for (;;)
    {
        if (write(pipefd[1],"a", 1) != -1)
        {
            cnt++;
        }
        else
            break;
    }

    printf("pipe size = % d bytes\n", cnt);
}
